<template>
  <div>
    <bookList :data="topBooks" :nav="''" isRank />

  </div>
</template>

<script>
import { mapGetters, mapActions, mapMutations } from 'vuex';
import bookList from '@/views/home/BookCenter/BookList.vue';
export default {
  data () {
    return {
      books: [],

    }
  },
  components: {
    bookList,
  },
  computed: {
    ...mapGetters(['getCategoryById', 'getMiniBook']),
    ...mapMutations(['setCurrentBook']),

    topBooks () {
      const tBook = this.books?.concat([]).splice(0, 9);
      return tBook;
    }
  },
  methods: {
    ...mapActions(['getAllCategory', 'getAllFile']),
    async fetchBook () {
      const { list } = await this.$api.getBookList({ size: 999 });
      list.forEach((item) => {
        item.lxInfo = this.getCategoryById(item.lx);
      });
      this.books = list;
    },
  },
  async created () {
    await this.fetchBook();
    await this.getAllFile();
    await this.getAllCategory();
  },
}
</script>

<style lang="less" scoped></style>
